package com.xh.bussiness.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.bussiness.course.bean.dto.CoursewareDetailDto;
import com.xh.bussiness.course.bean.request.CoursewareDetailRequest;
import com.xh.bussiness.course.dao.CoursewareDetailMapper;

import com.xh.bussiness.course.model.CoursewareDetail;
import com.xh.bussiness.course.service.ICoursewareDetailService;
import com.xh.bussiness.resource.service.IMaterialService;
import com.xh.core.service.impl.BaseServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;


import java.util.List;

@Service
public class CoursewareDetailSerivceImpl extends BaseServiceImpl<CoursewareDetailMapper, CoursewareDetail> implements ICoursewareDetailService {

    @Autowired
    private IMaterialService materialService;

    @Override
    public List query(CoursewareDetailRequest request) {
        QueryWrapper<CoursewareDetail> qw = new QueryWrapper<>();
        qw.eq("course_index_id",request.getCourseIndexId());
        qw.orderByAsc("order_no");
        List<CoursewareDetailDto> coursewareDetails = this.selectList(qw, CoursewareDetailDto.class);


        return coursewareDetails;
    }

    @Override
    public Integer modify(CoursewareDetailRequest request) {
        CoursewareDetail coursewareDetail = this.dao.selectById(request.getId());


        return this.dao.updateById(coursewareDetail);
    }

    @Override
    @Transactional
    public boolean save(List<CoursewareDetailRequest> request) {



        return true;
    }


}
